<?php
/**
 * Nweb Editor
 *
 * This script is protected by copyright. Its use, copying, modification
 * and distribution without written consent of the author is prohibited.
 *
 * @category    source
 * @package     pl.nweb.editor.view
 * @subpackage  helper
 * @author      Krzysztof Kardasz <krzysztof.kardasz@gmail.com>
 * @copyright   Copyright (c) 2012 Krzysztof Kardasz
 * @license     http://www.gnu.org/licenses/lgpl-3.0.txt  GNU Lesser General Public
 * @version     1.0 $Id$
 * @link        https://nweb-editor.googlecode.com
 * @link        http://editor.nweb.pl
 */

/**
 * Pomocnik widoku, ustawienia
 *
 * @category    source
 * @package     pl.nweb.editor.view
 * @subpackage  helper
 * @author      Krzysztof Kardasz <krzysztof.kardasz@gmail.com>
 * @copyright   Copyright (c) 2012 Krzysztof Kardasz
 * @version     1.0 $Id$
 */
class Zend_View_Helper_CachePartial extends \Zend_View_Helper_Abstract
{
    /**
     * Zwraca obiekt klasy
     *
     * @return Zend_View_Helper_CachePartial
     */
    public function cachePartial ()
    {
        return $this;
    }

    /**
     * Start bloku
     *
     * @param  string $name unikalna nazwa bloku
     * @return boolean
     */
    public function start ($name)
    {
        if(!Zend_Controller_Front::getInstance()->getRequest()->isPost()) {
            return \pl\nweb\editor\cache\Manager::getPartial()->start($name);
        }
        return false;
    }

    /**
     * Koniec bloku
     *
     * @return boolean
     */
    public function end ()
    {
        if(!Zend_Controller_Front::getInstance()->getRequest()->isPost()) {
            \pl\nweb\editor\cache\Manager::getPartial()->end();
            return true;
        }
        return false;
    }
}